package cn.qidd.keep.product.resource;

import cn.qidd.keep.domain.document.Product;
import cn.qidd.keep.feignclient.product.IProductService;
import cn.qidd.keep.product.repository.ProductRepository;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@RestController
public class ProductResource implements IProductService {

    @Resource
    private ProductRepository productRepository;

    @Override
    public String sayHello() {
        return "sayHello";
    }

    @Override
    public List<Product> getAllList() {
        return productRepository.findAll();
    }

    @Override
    public Product getProduct(@PathVariable String id) {
        return productRepository.findById(id).orElse(null);
    }
}
